package com.apes.fico.engine.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @program: apestech
 * @description: 机制凭证负责人配置
 * @author: Chengxm
 * @create: 2022-02-17 15:53
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = VoucherOwnerConfig.CONST_TABLE_NAME, indexes = {
        @Index(name = "IDX_MAS_VOUCHER_OWNER_CONFIG", columnList = "company_id,voucher_template_id", unique = true)
})
public class VoucherOwnerConfig extends Model {
    public final static String CONST_TABLE_NAME ="mas_voucher_owner_config";
    @Id
    @Column(name = "id", length = 8)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "机制凭证负责人配置")
    @Comment("编码")
    private String id;

    @Name
    @Comment("人员")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "person_id", referencedColumnName = "id", nullable = false)
    private PartyRole person;

    @Name
    @Comment("公司")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id", nullable = false)
    private PartyRole company;


    @Column(name = "voucher_template_id")
    @Comment("凭证模板")
    private String voucherTemplate;

    @Column(name = "voucher_template_name")
    @Comment("凭证模板名称")
    private String voucherTemplateName;
}
